package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmCas;
import com.ruoyi.web.admin.service.ITdmCasService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * CAS数据库管理Controller
 * 
 * @author ly
 * @date 2022-03-10
 */
@RestController
@RequestMapping("/admin/cas")
public class TdmCasController extends BaseController
{
    @Autowired
    private ITdmCasService tdmCasService;

    /**
     * 查询CAS数据库管理列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:cas:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmCas tdmCas)
    {
        startPage();
        List<TdmCas> list = tdmCasService.selectTdmCasList(tdmCas);
        return getDataTable(list);
    }

    /**
     * 导出CAS数据库管理列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:cas:export')")
    @Log(title = "CAS数据库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmCas tdmCas)
    {
        List<TdmCas> list = tdmCasService.selectTdmCasList(tdmCas);
        ExcelUtil<TdmCas> util = new ExcelUtil<TdmCas>(TdmCas.class);
        util.exportExcel(response, list, "CAS数据库管理数据");
    }

    /**
     * 获取CAS数据库管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:cas:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmCasService.selectTdmCasById(id));
    }

    /**
     * 新增CAS数据库管理
     */
//    @PreAuthorize("@ss.hasPermi('admin:cas:add')")
    @Log(title = "CAS数据库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmCas tdmCas)
    {
        return toAjax(tdmCasService.insertTdmCas(tdmCas));
    }

    /**
     * 修改CAS数据库管理
     */
//    @PreAuthorize("@ss.hasPermi('admin:cas:edit')")
    @Log(title = "CAS数据库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmCas tdmCas)
    {
        return toAjax(tdmCasService.updateTdmCas(tdmCas));
    }

    /**
     * 删除CAS数据库管理
     */
//    @PreAuthorize("@ss.hasPermi('admin:cas:remove')")
    @Log(title = "CAS数据库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmCasService.deleteTdmCasByIds(ids));
    }
}
